import {TextComponent} from "./text/text.component";
import {IdentityComponent} from "./identity/identity.component";
import {NumberComponent} from "./number/number.component";
import {MoneyComponent} from "./money/money.component";
import {CalcComponent} from "./calc/calc.component";
import {CheckboxComponent} from "./checkbox/checkbox.component";
import {DropdownComponent} from "./dropdown/dropdown.component";
import {MemberComponent} from "./member/member.component";
import {DatetimeComponent} from "./datetime/datetime.component";
import {ImageComponent} from "./image/image.component";
import {AttachmentComponent} from "./attachment/attachment.component";
import {LocationComponent} from "./location/location.component";
import {RelationComponent} from "./relation/relation.component";
import {InjectionToken} from "@angular/core";

class FieldType {
  group: string;
  type: string;
  name: string;
  icon: string;
  component: any
}

const FieldDefinition: any = {list: []};
FieldDefinition.list = new Array<FieldType>(
  // Group 1
  {group: "01", name: "文本", type: "text", icon: "\ue011", component: TextComponent},
  {group: "01", name: "号码", type: "identity", icon: "\ue035", component: IdentityComponent},
  // Group 2
  {group: "02", name: "数值", type: "number", icon: "\ue036", component: NumberComponent},
  {group: "02", name: "金额", type: "money", icon: "\ue038", component: MoneyComponent},
  {group: "02", name: "计算", type: "calc", icon: "\ue039", component: CalcComponent},
  // Group 3
  {group: "03", name: "选择", type: "checkbox", icon: "\ue040", component: CheckboxComponent},
  {group: "03", name: "下啦菜单", type: "dropdown", icon: "\ue041", component: DropdownComponent},
  // Group 4
  {group: "04", name: "工作区成员", type: "member", icon: "\ue042", component: MemberComponent},
  {group: "04", name: "日期和时间", type: "datetime", icon: "\ue043", component: DatetimeComponent},
  {group: "04", name: "图片", type: "image", icon: "\ue044", component: ImageComponent},
  {group: "04", name: "附件", type: "attachment", icon: "\ue045", component: AttachmentComponent},
  {group: "04", name: "位置", type: "location", icon: "\ue046", component: LocationComponent},
  {group: "04", name: "关联其他表格", type: "relation", icon: "\ue047", component: RelationComponent},
);
FieldDefinition.list.forEach(field => {
  FieldDefinition[field.type] = field;
})

const FieldRef = new InjectionToken<string>('field.ref');
const FieldSource = new InjectionToken<string>('field.source');

export {FieldDefinition, FieldRef, FieldSource}
